package com.game.view.scene
{
	import com.game.element.AK47;
	import com.game.element.BaseElement;
	import com.game.element.Bullet;
	import com.game.element.PlayerElement;
	import com.game.res.UIRescource;
	import com.interfaces.game.GlobalAPI;
	import com.interfaces.general.mangaer.ITick;
	
	import fl.core.UIComponent;
	
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	public class SceneView extends UIComponent implements ITick
	{
		public var playerView:PlayerElement;
		
		public function SceneView()
		{
			super();
		}
		
		private function clickHandler(e:Event):void{
			if(playerView == null){
				return;
			}
			playerView.fire(new Point(this.mouseX,this.mouseY));
		}
		
		private function mouseDownHandler(e:Event):void{
			if(playerView == null){
				return;
			}
			playerView.baseWeapon.startFire();
		}
		
		private function mouseUpHandler(e:Event):void{
			if(playerView == null){
				return;
			}
			playerView.baseWeapon.stopFire();
		}
		
		public function initPlayer():void{
			playerView = new PlayerElement;
			playerView.x = 150;
			playerView.y = 150;
			
			playerView.equipWeapon(new AK47);
			
			this.stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
			this.stage.addEventListener(MouseEvent.MOUSE_UP,mouseUpHandler);
			addChild(playerView);
			GlobalAPI.tickManager.regeditTick(playerView);
		}
		
		public function addBullets(bullet:Bullet):void{
			GlobalAPI.tickManager.regeditTick(bullet);
			addChild(bullet);
		}
		
		public function exce():void
		{
		}
		
		public function set tickPriority(priority:int):void
		{
		}
		
		public function get tickPriority():int
		{
			return 0;
		}
	}
}